package es.onlysolutions.gs.comm.filter;

import es.onlysolutions.arq.core.filter.CriteriaFilter;
import es.onlysolutions.arq.core.auth.UserManager;
import es.onlysolutions.gs.comm.utils.UserSettings;
import es.onlysolutions.gs.comm.entity.User;
import org.hibernate.criterion.Restrictions;

/**
 * filter for the list of videos being processed.
 */
public class VideoProcessFilter extends VideoFilter
{

    public VideoProcessFilter()
    {
        //always filter for user in session.
        UserSettings userSettings = (UserSettings) UserManager.instance().getUser();

        //If user is null, we are not under session, so list all, the filer is not where to check this.
        if( userSettings != null )
        {
            User userToList = userSettings.getUser();
            addRestriction(Restrictions.eq("user", userToList));
        }

        addAscOrder("title");
    }
}
